#include <iostream>
using namespace std;

class Date {
public:
    Date(int y, int n)
        : _year(y)
        , _month(1)
        , _day(n)
    {}

    bool isleapyear() {
        if (_year % 4 == 0 && _year % 100 != 0 || _year % 400 == 0)
            return true;
        else return false;
    }

    int getmonthday() {
        int arr[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        if (isleapyear()) {
            arr[2] = 29;
        }
        return arr[_month];
    }

    void ChangeDate() {
        while (_day > getmonthday()) {
            _day -= getmonthday();
            _month++;
            if (_month == 13) {
                _month = 1;
                _year++;
            }
        }
    }

    int getyear() {
        return _year;
    }
    int getmonth() {
        return _month;
    }
    int getday() {
        return _day;
    }
private:
    int _year;
    int _month;
    int _day;
};

int main() {
    int y, n;
    while (scanf("%d %d", &y, &n) != EOF) {
        Date d(y, n);

        d.ChangeDate();

        printf("%04d-%02d-%02d\n", d.getyear(), d.getmonth(), d.getday());
    }
    return 0;
}